﻿using System.Collections.Generic;

namespace SLNGP.Core.Run
{
    public class GeneticProgrammingRun : IGeneticProgrammingRun
    {
        public GeneticProgrammingRun()
        {
            Variables = new Dictionary<string, object>();
        }

        public void InitializeVariablesFromUntypedListOfObjects(object[] _variables)
        {
            if (_variables.Length % 2 != 0)
                throw new GeneticProgrammingException("The number of parameters used for variables must be even. Pairs of variables names and variables values.");

            for (int i = 0; i < _variables.Length; i = i + 2)
            {
                Variables[(string)_variables[i]] = _variables[i + 1].ToString();
            }
        }

        public Dictionary<string, object> Variables { get; set; }
    }
}